<template>
  <div class="main main_bg" :style="$store.state.isApp?'paddingTop:0':'paddingTop:1.2rem'">
    <gltitle :titleSize="titleSize" :is_mt="is_mt" ></gltitle>

    <div class="box">
      <ul class="a_list bg-fff">
        <li class="db" :class="{on:cid === k}" v-for="(item,k) in datalist" :key="k" @click="checkbox(item.code,k)">
          <div class="flex">{{item.name}}</div>
          <div class="str"><span class="ico"></span></div>
        </li>
      </ul>
      <ul class="a_list bg-fff">
        <li>
          <textarea name="" v-model="text" :placeholder="$t('feedback.plass_title')" cols="30" rows="10"></textarea>
        </li>
      </ul>

    </div>


    <div class="container">
      <button class="btn" @click="go">{{$t('word.btn2')}}</button>
    </div>
  </div>
</template>
<script>


  export default {
    data(){
      return {
        titleSize:this.$t('title.feedback'),
        is_mt:true,
        datalist:[],
        cid:'',
        text:'',
        id:'',
      }
    },

    components: {

    },
    created(){
      this.getinfo()
    },
    mounted() {


    },
    methods: {
      checkbox(id,k){
        this.cid = k
        this.id = id

      },
      go(){
        if(this.id === ''){
          //this.$toast('请选择要反馈的意见类型');
          this.$toast(this.$t('feedback.please_input'));
          return
        }
        if(this.text === ''){
          //this.$toast('意见内容不能为空');
          this.$toast(this.$t('feedback.not_null'));
          return
        }
        this.$post(this.URL.member.feedback_create, {
          type:this.id,
          context:this.text
        }).then((res) => {
          if (res.code == 0) {
            //this.$toast.success('反馈成功');
            this.$toast(this.$t('feedback.successed'));
            this.$router.push("/user");
          } else {
            this.$toast(res.message);
          }
        });
      },
      getinfo(){
        this.$post(this.URL.member.feedback_list, {

        }).then((res) => {
          if (res.code == 0) {
            this.datalist = res.data
          } else {
            this.$toast(res.message);
          }
        });
      },

    },


  }

</script>


<style lang="less" scoped>
  #app {
    .box {
      margin-bottom: 1rem;
    }
  }
</style>
